package com.qingyun.edusysteam.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.BooleanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qingyun.edusysteam.dto.Result;
import com.qingyun.edusysteam.utils.UserHolder;
import com.qingyun.edusysteam.vo.StudentInfoVO;
import com.qingyun.edusysteam.dto.UserDTO;
import com.qingyun.edusysteam.entity.Student;
import com.qingyun.edusysteam.mapper.StudentMapper;
import com.qingyun.edusysteam.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import static com.qingyun.edusysteam.utils.RedisConstants.LOGIN_USER_KEY;

/**
 * <p>
 * 学生表 服务实现类
 * </p>
 *
 * @author your_name
 * @since 2025-08-23
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements IStudentService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private UserHolder userHolder;
    @Override
    public Result studentInfo(String token, String keyword) {
        Long teacherId = userHolder.getUserId();
        if (teacherId == null) {
            return Result.fail("用户未登录或Token失效");
        }
        List<StudentInfoVO> userDTOS = studentMapper.studentInfo(teacherId, keyword);
        if (userDTOS.isEmpty()) {
            return Result.fail("暂无学生信息");
        }
        return Result.ok(userDTOS);
    }
}
